package com.yyfax.ph.home.imageupload;

import android.os.Parcel;
import android.os.Parcelable;

import com.yyfax.ph.common.utils.Constants;
import com.yyfax.ph.common.imageselector.activity.PhotoSelectorActivity;
import com.yyfax.ph.common.imageselector.bean.ImageBean;

import java.util.ArrayList;

/**
 * 图片选择所需参数
 * Created by laixj on 2017/4/18.
 * Copyright ©2017 www.yylending.com. All Rights Reserved.
 */

public class ImageSelectArguments implements Parcelable {
	/**
	 * 单选或多选
	 */
	public int selectMode = PhotoSelectorActivity.SELECT_MODE_MULTI;
	/**
	 * 已选择的图片
	 */
	public ArrayList<String> selectedImages = new ArrayList<>();
	/**
	 * 已压缩图片
	 */
	public ArrayList<ImageBean> compressedImages = new ArrayList<>();
	/**
	 * 剩余最大可传照片张数
	 */
	public int remainCount = Constants.MAX_IMAGE_COUNT_DEFAULT;
	/**
	 * 最大最大可传照片张数
	 */
	public int maxCount = Constants.MAX_IMAGE_COUNT_DEFAULT;
	/**
	 * 宽度
	 */
	public int targetWidth = 720;
	/**
	 * 高度
	 */
	public int targetHeight = 1080;
	/**
	 * 是否显示camera
	 */
	public boolean showCamera = true;

	@Override
	public String toString() {
		return "ImageSelectArguments{" +
				"selectMode=" + selectMode +
				", selectedImages=" + selectedImages +
				", compressedImages=" + compressedImages +
				", remainCount=" + remainCount +
				", maxCount=" + maxCount +
				", targetWidth=" + targetWidth +
				", targetHeight=" + targetHeight +
				", showCamera=" + showCamera +
				'}';
	}

	public ImageSelectArguments() {
	}

	@Override
	public int describeContents() {
		return 0;
	}

	@Override
	public void writeToParcel(Parcel dest, int flags) {
		dest.writeInt(this.selectMode);
		dest.writeStringList(this.selectedImages);
		dest.writeTypedList(this.compressedImages);
		dest.writeInt(this.remainCount);
		dest.writeInt(this.maxCount);
		dest.writeInt(this.targetWidth);
		dest.writeInt(this.targetHeight);
		dest.writeByte(this.showCamera ? (byte) 1 : (byte) 0);
	}

	protected ImageSelectArguments(Parcel in) {
		this.selectMode = in.readInt();
		this.selectedImages = in.createStringArrayList();
		this.compressedImages = in.createTypedArrayList(ImageBean.CREATOR);
		this.remainCount = in.readInt();
		this.maxCount = in.readInt();
		this.targetWidth = in.readInt();
		this.targetHeight = in.readInt();
		this.showCamera = in.readByte() != 0;
	}

	public static final Creator<ImageSelectArguments> CREATOR = new Creator<ImageSelectArguments>() {
		@Override
		public ImageSelectArguments createFromParcel(Parcel source) {
			return new ImageSelectArguments(source);
		}

		@Override
		public ImageSelectArguments[] newArray(int size) {
			return new ImageSelectArguments[size];
		}
	};
}
